package net.imagine.backend.mockrmi.remote.provider.netty.server;

import net.imagine.backend.mockrmi.remote.server.Server;
import net.imagine.backend.mockrmi.remote.server.ServerFactory;

import org.apache.commons.collections.FastHashMap;

/**
 * 使用Netty框架实现的ServerFactory，用于创建Netty的实现的Server对象
 * 
 * @author wuqh
 * @see ServerFactory
 * @see NettyServer
 */
public class NettyServerFactory implements ServerFactory {
	private FastHashMap servers;

	public NettyServerFactory() {
		servers = new FastHashMap();
		servers.setFast(true);
	}

	public Server getServer(int port) {
		NettyServer server = (NettyServer) servers.get(port);
		if (server == null) {
			server = new NettyServer(port);
			servers.put(port, server);
		}
		return server;
	}
}
